import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersistence from 'vuex-persist'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        list: [],
        finish: [],
        nofinish:[]
    },
    mutations: {
        add(state,obj){
            state.list.push(obj)
            console.log(state.list);
        },
        toUpdate(state, obj) {
            state.list=obj
        },
        Del(state,index) {
            state.list.splice(index,1)
        },
        Finish(state) {
            state.finish = state.list.filter(item => {
                return item.checked===true
            })
        },
        noFInish(state) {
            state.nofinish = state.list.filter(item => {
                return item.checked === false
            })
        },
        delarr(state) {
            state.list = [];
            state.finish = [];
            state.nofinish = [];
        }

    },
    getters: {
        
    },
    actions:{
        
    },
    plugins: [new VuexPersistence().plugin]
})